package custom;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.qianfeng.lingshijia.R;

import utils.DownloadUtils;

/**
 * Created by Administrator on 2016/1/13.
 */
public class DetailMidView extends LinearLayout {

    private ImageView imageView;
    private TextView title,price,salesVolume;
    public DetailMidView(Context context) {
        super(context);
        init();
    }

    public DetailMidView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.detail_head_item, this);
        imageView = (ImageView) findViewById(R.id.id_iv_details);

        title = (TextView) findViewById(R.id.id_title_details);
        price = (TextView) findViewById(R.id.id_details_price);
        salesVolume = (TextView) findViewById(R.id.id_tv_salesVolume);
        salesVolume.setVisibility(GONE);
    }

    public void setData(String imgurl,String price,String sales,String title){
        DownloadUtils.LoadPicture(imgurl, imageView);
        this.title.setText(title);
        this.price.setText("¥"+price);
        if(sales!=null){
            this.salesVolume.setVisibility(VISIBLE);
            this.salesVolume.setText("月销量  :  "+sales);
        }

    }


}
